package com.nexus.all.manager;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nexus.all.dao.RequestLogMapper;
import com.nexus.all.model.RequestLog;
import com.nexus.web.service.LoggingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;


/**
 * 请求日志通用逻辑层-管理类
 *
 * @author zxt
 * @version 1.0
 * @CopyRright (c): <?>
 */
@Slf4j
@Service
public class RequestLogManager extends ServiceImpl<RequestLogMapper, RequestLog> implements LoggingService {


    @Override
    @Async
    public void saveLog(String ip, String method, String uri, String queryStr, String protocol, Integer status, Integer timeUsed, String traceId) {
        RequestLog requestLog = new RequestLog();
        requestLog.setRequestIp(ip);
        requestLog.setRequestMethod(method);
        requestLog.setRequestUri(uri);
        requestLog.setRequestParam(queryStr);
        requestLog.setRequestProtocol(protocol);
        requestLog.setResponseStatus(status);
        requestLog.setResponseTime(timeUsed);
        requestLog.setResponseTraceId(traceId);
        save(requestLog);
    }
}
